package com.example;

import com.example.service.DbConnectionService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

import java.sql.SQLException;

import static org.junit.jupiter.api.Assertions.*;

@Slf4j
public class AppTest {
	@Test
	void shouldAnswerWithTrue() {
		assertTrue(true);
	}

	@Test
	void testDbConnection() {
		DbConnectionService dbConnectionService = new DbConnectionService();
		try {
			dbConnectionService.testConnection("jdbc:mysql://192.168.225.132:3306/cloud-test", "root", "12345");
			log.info("数据库连接成功");
		} catch (SQLException e) {
			System.out.println("Error Code: " + e.getErrorCode());  // 错误代码
			System.out.println("SQLState: " + e.getSQLState());      // SQLState
			System.out.println("Error Message: " + e.getMessage());  // 错误消息
		}
	}
} 